package com.kaigejava.iterator.conventional;

import com.kaigejava.iterator.MenuItem;

/**
 * Created by kaigejava on 2019/9/6.
 * 传统模式下-网易考拉的午餐店菜单
 */
public class DinerMenu {
    //设置菜单最多5个
    private final static int Max_Items=5;
    //设置菜单初始化是从第0个个开始
    public int numberOfItems=0;
    //菜单项数组
    private MenuItem[] menuItems;

    public DinerMenu()
    {
        menuItems=new MenuItem[Max_Items] ;
        addItem("蔬菜 熏肉","熏肉&生菜&番茄&甘蓝",true,3.58f);
        addItem("熏肉","熏肉&生菜&番茄",false,3.00f);
        addItem("豆汤","豆子&土豆沙拉",true,3.28f);
        addItem("热狗","洋葱&奶酪&面包",false,3.05f);

    }

    /**
     * 向菜单中添加菜单项
     * @param name
     * @param description
     * @param vegetable
     * @param price
     */
    private void addItem(String name, String description, boolean vegetable,
                         float price) {
        MenuItem menuItem = new MenuItem(name, description, vegetable, price);
        if(numberOfItems>=Max_Items)
        {
            System.err.println("对不起，菜单满了！无法添加其他项");
        }else{
            menuItems[numberOfItems]=menuItem;
            numberOfItems++;
        }
    }

    public MenuItem[] getMenuItems() {
        return menuItems;
    }
}
